// ServerCalculator.cc
#include <functional>
#include <memory>
#include "TcpServer.hpp"
#include "ServerCal.hpp"

void Usage(const std::string &proc)
{
    std::cout << "\n\rUsage: " << proc << " port[1024+]\n"
              << std::endl;
}

// ./servercal 8080
int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        Usage(argv[0]);
        exit(UsageErr);
    }
    uint16_t port = std::stoi(argv[1]);

    ServerCal cal;
    std::unique_ptr<TcpServer> tcp_ser(new TcpServer(port, std::bind(&ServerCal::Calculator, &cal, std::placeholders::_1)));
    tcp_ser->InitServer();
    tcp_ser->Start();

    return 0;
}